package com.icat.house.model;

import com.jfinal.ext.plugin.tablebind.TableBind;
import com.jfinal.plugin.activerecord.Db;

@TableBind(tableName = "user_trade_room")
public class UserTradeRoom extends BaseModel<UserTradeRoom> {

	private static final long serialVersionUID = 1L;
	public static final UserTradeRoom dao = new UserTradeRoom();

	/**
	 * 保存用户交易信息
	 * 
	 * @param user_id
	 * @param room_id
	 * @return
	 */
	public boolean save(int user_id, String room_id, int status) {
		UserTradeRoom room = new UserTradeRoom();
		room.set("user_id", user_id);
		room.set("room_id", room_id);
		room.set("status", status);
		return room.save();
	}

	public boolean deleteHouseTrade(int user_id, String room_id) {
		return Db.update("delete from user_trade_room where user_id=? and room_id=? ", user_id, room_id) > 0;
	}

	public UserTradeRoom getUserTradeRoom(int user_id, String room_id, int status) {
		return findFirst("select id,status,user_id from user_trade_room where user_id=? and room_id=? and status=?",
				user_id, room_id, status);
	}
}
